package com.baizhi.cmfzmanager.service.impl;

import com.baizhi.cmfzmanager.dao.LessonDao;
import com.baizhi.cmfzmanager.entity.Lesson;
import com.baizhi.cmfzmanager.service.LessonService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Service
public class LessonServiceImpl implements LessonService {
    @Autowired
    private LessonDao lessonDao;
    @Override
    public Map getLessons(Integer page, Integer rows) {
        int totl=lessonDao.getcount();
        int start=(page-1)*rows;
        System.out.println(lessonDao);
        List<Lesson> list=lessonDao.getLessons(start,rows);
        Map map=new HashMap();
        map.put("total", totl);
        map.put("rows", list);
        return map;
    }

    @Override
    public void addLesson(Lesson lesson) {
        lessonDao.add(lesson);
    }

    @Override
    public void deleteLesson(int[] id) {
        lessonDao.delete(id);
    }
}
